package com.xiaoyao.novel.action.phone;

import java.util.List;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.xiaoyao.novel.action.page.NovelAction;
import com.xiaoyao.novel.pojo.Category;
import com.xiaoyao.novel.pojo.WebInfo;

public class AndroidAction extends NovelAction {
	private static final long serialVersionUID = 1L;

	private int userId; // 暂时没用
	private String action;
	private int version;

	private String serial = "";
	private String simStatus = "";
	private String model = "";
	private String simSerial;

	private int newVersion;

	public void api() throws Exception {
		// action,version,serial,ip,simStatus,model,simSerial,
		logger.warn("参数:" + action + "/" + version + "/" + serial + "/" + getIp() + "/" + simStatus + "/" + model + "/" + simSerial);
		String msg = "";
		JSONObject resultObject = new JSONObject();
		JSONObject dataObject = new JSONObject();
		JSONArray jsonArray = new JSONArray();
		WebInfo webInfo = webInfoService.getStaticWebInfo();
		 
		if ("1001".equals(action)) { // 首页(推荐列表,新书列表)
			resultObject.put("rList", jsonArray);
			resultObject.put("nList", jsonArray);
		} else if ("1002".equals(action)) { // 分类列表
			List<Category> list= categoryService.getAll();
			resultObject.put("list", jsonArray);
		} else if ("1003".equals(action)) { // 搜索,分类搜索
			resultObject.put("list", jsonArray);
		} else if ("1004".equals(action)) { // 书籍详情
			resultObject.put("data", dataObject);
		} else if ("1005".equals(action)) { // 书籍章节列表
			resultObject.put("list", dataObject);
		} else if ("1006".equals(action)) { // 章节内容
			resultObject.put("data", dataObject);
		}
		resultObject.put("newVersion", newVersion);
		resultObject.put("updateMsg", "更新内容");
		resultObject.put("msg", msg);
		String result = resultObject.toString();
		logger.info("结果:" + result);
		output(result);
	}
}
